//
// Created by wangjunjun on 2024/3/20.
//

#ifndef HTTPRESQUEST_H
#define HTTPRESQUEST_H

#include "../log/log.h"
#include <string>
#include <curl/curl.h>
#include <memory>
#include <mutex>
struct RequestBody{
    std::string robotSn;
    std::string dateTime;
    std::string position;
    std::string  msg;
};
struct  ResponseBody{
    std::string url;
    int code; //状态码
};
class HttpResquest {

public:
    static std::shared_ptr<HttpResquest> GetInStance();
    bool SendRequest(const std::string& url , const RequestBody& requestBody, ResponseBody& response);

private:
    HttpResquest();
    ~HttpResquest();
    static size_t WriteCallback(void* contents, size_t size, size_t nmemb, std::string* response);
private:
    static  std::shared_ptr<HttpResquest> m_InStance;
    static  std::once_flag m_flag;

};


#endif //WLROBOTICS_HTTPRESQUEST_H
